import request from '@/utils/request'

// 查询生产工单列表
export function listWorkOrder(query) {
  return request({
    url: '/production/workorder/list',
    method: 'get',
    params: query
  })
}

// 查询生产工单详细
export function getWorkOrder(orderId) {
  return request({
    url: '/production/workorder/' + orderId,
    method: 'get'
  })
}

// 新增生产工单
export function addWorkOrder(data) {
  return request({
    url: '/production/workorder',
    method: 'post',
    data: data
  })
}

// 修改生产工单
export function updateWorkOrder(data) {
  return request({
    url: '/production/workorder',
    method: 'put',
    data: data
  })
}

// 删除生产工单
export function delWorkOrder(orderId) {
  return request({
    url: '/production/workorder/' + orderId,
    method: 'delete'
  })
}

// 校验工单编号
export function checkOrderCodeUnique(params) {
  return request({
    url: '/production/workorder/checkOrderCodeUnique',
    method: 'get',
    params: params  // 改为接收完整的参数对象，支持 orderCode 和 orderId
  })
}

// 根据计划ID查询工单列表
export function listByPlanId(planId) {
  return request({
    url: '/production/workorder/listByPlanId/' + planId,
    method: 'get'
  })
}